//加入收藏
function addFavorite(){
   if (document.all){
      window.external.addFavorite("http://"+document.location.host+"/",document.title);
   }else if (window.sidebar){
      window.sidebar.addPanel(document.title,"http://"+document.location.host+"/", "");
   }
}
//设为首页
function setHomepage(){
   if(document.all){
      document.body.style.behavior="url(#default#homepage)";
      document.body.setHomePage("http://"+document.location.host+"/");
   }
   else if(window.sidebar){
        if(window.netscape){
             try{
                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
             }
             catch(e){
                 alert("您的浏览器未启用[设为首页]功能，开启方法：先在地址栏内输入about:config,然后将项 signed.applets.codebase_principal_support 值该为true即可");
             }
        }
        var prefs=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref("browser.startup.homepage","http://"+document.location.host+"/");
   }
}

$(document).ready(function(){
    //query list tabpage
    $( '.tab-page ul:not(:first)' ).hide();

    $('.tab-nav li').click(function(e) {
        $('.tab-page ul').hide();
        $('.tab-nav .current').removeClass("current");
        $(this).find('a:first').addClass('current');

        var clicked = $(this).find('a:first').attr('href');
        $('.tab-page ' + clicked).show();

        e.preventDefault();
    }).eq(0).find('a:first').addClass('current');

    //set homepage
    $('#homepage').click(function(){
        setHomepage();
    });
    
    //set favorite
    $('#favorite').click(function(){
        addFavorite();
    });
});
